#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
//class Solution {
//public:
//    int maxArea(vector<int>& height) {
//        vector<int> dp(height.size(), 0);
//        int maxh[2] = { 0,0 };
//        for (int i = 1; i < height.size(); i++)
//        {
//            dp[i] = max(dp[i - 1], (maxh[1] - maxh[0]) * min(height(maxh[1]), height(maxh[0])))
//        }
//        return dp[height.size()];
//    }
//};
class Solution {
public:
    int maxArea(vector<int>& height) {
        int ma = 0;
        int i = 0;
        int j = height.size() - 1;
        int maxh[2] = { i,j };
        while (i < j)
        {
            int Area = max((maxh[1] - maxh[0]) * min(height[maxh[1]], height[maxh[0]]), Area);
            i++;
            j--;
            maxh[0] = max(i, maxh[0]);
            maxh[1] = max(j, maxh[1]);
        }
    }
};